package game;

import java.awt.Dimension;

public class Position
{
    private int x;
    private int y;
    
    public Position(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
    
    public Position(Dimension d)
    {
        this(d.width, d.height);
    }

    public int getX()
    {
        return x;
    }

    public void setX(int x)
    {
        this.x = x;
    }

    public int getY()
    {
        return y;
    }

    public void setY(int y)
    {
        this.y = y;
    }

    public int getWidth()
    {
        return x;
    }

    public void setWidth(int width)
    {
        this.x = width;
    }

    public int getHeight()
    {
        return y;
    }

    public void setHeight(int height)
    {
        this.y = height;
    }
    
    public int getSum()
    {
        return getX() * getY();
    }
    
    @Override
    public int hashCode()
    {
        return Util.byteArrayToInt(toString().getBytes());
    }
    
    @Override
    public boolean equals(Object obj)
    {
        boolean result = false;
        if (obj instanceof Position)
        {
            result = (((Position) obj).getX() == getX() &&
                      ((Position) obj).getY() == getY());
        }
        return result;
    }
    
    @Override
    public String toString()
    {
        return "x=" + getX() + ";h=" + getY() + ";";
    }
}
